package com.zou;

public class Ticket12306 {

    private int ticketsTotal = 50; //数据库的票总数

    private int ticketsCurrent = ticketsTotal; //当前剩余票数

    public Ticket12306(){
    }

    public Ticket12306(int tickets){
        this.ticketsTotal = tickets;
    }

    /**
     * 获取一张票
     * @param component 其他公司： 飞猪 携程 去哪儿 智行
     */
    public String getTicket(String component) {

        //票数量> 0 时, 继续递减
        if(ticketsCurrent > 0 ){
            ticketsCurrent--;
        }

        return Thread.currentThread().getName()+"[" + component + "]: 总票数 = " + ticketsTotal + ", 剩余票数 = " + ticketsCurrent;
    }


}
